#pragma once

const std::string opers = "+-*/(@&%";
enum
{
    ok = 0,
    div_zero,
    mod_zero,
    unknow
};
class Task
{
public:
    Task()
    {
    }
    Task(int x, int y, char op)
        : _data_x(x), _data_y(y), oper(op), result(0), code(ok)
    {
    }

    void Run()
    {
        switch (oper)
        {
        case '+':
            result = _data_x + _data_y;
            break;
        case '-':
            result = _data_x - _data_y;
            break;
        case '*':
            result = _data_x * _data_y;
            break;
        case '/':
        {
            if (_data_y == 0)
                code = div_zero;
            else
                result = _data_x / _data_y;
        }
        break;
        case '%':
        {
            if (_data_y == 0)
                code = mod_zero;
            else
                result = _data_x % _data_y;
            break;
        }
        default:
        {
            code = unknow;
        }
        break;
        }
    }

    std::string Printresult()
    {
        std::string res;
        res += std::to_string(_data_x);
        res += oper;
        res += std::to_string(_data_y);
        res += "=";
        res += std::to_string(result);
        res += '[';
        res += std::to_string(code);
        res += ']';
        return res;
    }
    std::string PrintTask()
    {
        std::string res;
        res += std::to_string(_data_x);
        res += oper;
        res += std::to_string(_data_y);
        res += "=?";
        return res;
    }

private:
    int _data_x;
    int _data_y;
    char oper; // + - * / %
    int result;
    int code; // 结果是否正确
};
